package edu.gatech.cs2340.thecyclonesquad;

import edu.gatech.cs2340.thecyclonesquad.database.Database;
import edu.gatech.cs2340.thecyclonesquad.models.InMemoryModel;
import android.os.Build;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class FoundItemsActivity extends Activity {
	

	private ArrayAdapter<String> mListData;

	/**
	 * Initializes our activity.
	 */
	@SuppressLint("NewApi")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_found_items);
		// Make sure we're running on Honeycomb or higher to use ActionBar APIs
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            // Show the Up button in the action bar.
            getActionBar().setDisplayHomeAsUpEnabled(true);
        }
        Database entry = new Database(this);
    	entry.open();
    	String items[] = entry.getItems("Found");
    	entry.close();
        //get handle of list
        ListView lvList = (ListView)findViewById(R.id.listView1);
        //creates an adapter to hold values for the list
        //Array adapter constructor has a List Item layout and the context
        mListData = new ArrayAdapter<String>(FoundItemsActivity.this, android.R.layout.simple_list_item_1, items);
        //Set adapter to the list
        lvList.setAdapter(mListData);
	}
	
	/*protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
	}*/

	/**
	 * Initialize the contents of the Activity's standard options menu.
	 */
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_found_items, menu);
		return true;
	}

	/**
	 * Goes to filter category screen.
	 * @param view is the basic building block for UI components
	 */
	public void filterCategory(View view) {
		Intent intent = new Intent(this, FilterCategoryActivity.class);
		startActivity(intent);			
	}
	
	/**
	 * Goes to filter status screen.
	 * @param view is the basic building block for UI components
	 */
	public void filterStatus(View view) {
		Intent intent = new Intent(this, FilterStatusActivity.class);
		startActivity(intent);			
	}
	/**
	 * Goes to filter date screen.
	 * @param view is the basic building block for UI components
	 */
	public void filterDate(View view) {
		Intent intent = new Intent(this, FilterDateActivity.class);
		startActivity(intent);			
	}
	
	/**
	 * logOut method logs the user out and goes back to login page.
	 * @param view is the basic building block for UI components
	 */
	public void logOut(View view) {
		Intent intent = new Intent(this, SignInActivity.class);
		startActivity(intent);			
	}
	
}
